package cn.itsource.ymcc.service.impl;

import cn.itsource.ymcc.domain.Employee;
import cn.itsource.ymcc.mapper.EmployeeMapper;
import cn.itsource.ymcc.service.IEmployeeService;
import cn.itsource.ymcc.utils.jwt.UserContext;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zongcj
 * @since 2023-09-10
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {

    @Override
    public Employee getCurrentEmp(HttpServletRequest request) {
        String token = request.getHeader("Token");
        Long userId = UserContext.getUserId(token);
        Employee one = super.getOne(new LambdaQueryWrapper<Employee>().eq(Employee::getLoginId, userId));
        return one;
    }
}
